package controller

import (
	"sale-admin/config/mysql"
	"sale-admin/internal/app/web/service"
	"sale-admin/internal/app/web/service/common"
	"sale-admin/internal/app/web/service/robot"
	"sale-admin/internal/app/web/service/statistics"
	"sale-admin/internal/dal"
	"sale-admin/internal/dao"
	"strconv"
	"strings"

	"192.168.1.75/go-pkg/errorx"
	"192.168.1.75/go-pkg/response"
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
	"github.com/samber/lo"
)

type Statistics struct{}

func (s Statistics) DataCompare(c *gin.Context) {
	var params struct {
		StartTime string `json:"start_time"`
		EndTime   string `json:"end_time"`
		Field     string `json:"field"`
		Areas1    string `json:"areas1"`
		Areas2    string `json:"areas2"`
		Areas3    string `json:"areas3"`
		GoodsID   string `json:"goods_id"`
		SalesID   string `json:"sales_id"`
		ShopID    string `json:"shop_id"`
	}
	err := c.ShouldBindBodyWith(&params, binding.JSON)
	if err != nil {
		response.JSON(c, nil, errorx.New("参数错误", -1))
		return
	}
	merchantID := c.GetString("merchant_id")
	db := mysql.NewDB()
	data, err := statistics.StatisticsService{}.DataCompare(c.Request.Context(), db, merchantID, params.StartTime,
		params.EndTime, params.Field, params.Areas1, params.Areas2, params.Areas3, params.GoodsID, params.SalesID, params.ShopID)
	response.JSON(c, data, err)
}

// 首页订单相关统计
func (s Statistics) OrderCount(c *gin.Context) {
	var params struct {
		ShopID *[]string `json:"shopid"`
	}
	err := c.ShouldBindBodyWith(&params, binding.JSON)
	if err != nil {
		response.JSON(c, nil, errorx.New("参数错误", -1))
		return
	}
	merchantID := c.GetString("merchant_id")
	merchantName := c.GetString("merchant_name")
	db := mysql.NewDB()
	//
	data, err := statistics.StatisticsService{}.OrderCount(c.Request.Context(), db, merchantID, merchantName, params.ShopID)

	// 返回json结果
	response.JSON(c, data, err)

}

// 异常设备列表
func (s Statistics) AbnormalDevice(c *gin.Context) {
	var params struct {
		Type      int    `json:"type"`   // 1曝光 2 点击 3 创单
		Areas1    string `json:"areas1"` // 省
		Areas2    string `json:"areas2"` // 市
		Page      int    `json:"page"`
		Limit     int    `json:"limit"`
		StartTime int64  `json:"start_time"`
		EndTime   int64  `json:"end_time"`
	}
	err := c.ShouldBindBodyWith(&params, binding.JSON)
	if err != nil {
		response.JSON(c, nil, errorx.New("参数错误", -1))
		return
	}
	merchantID := c.GetString("merchant_id")
	db := mysql.NewDB()
	data, err := statistics.StatisticsService{}.AbnormalDevice(c.Request.Context(), db, merchantID,
		params.Type, params.Areas1, params.Areas2, params.StartTime, params.EndTime, params.Page, params.Limit,
	)
	response.JSON(c, data, err)
}

// Draw 客户画像
func (s Statistics) Draw(c *gin.Context) {
	var params struct {
		GoodsName   string    `json:"goods_name"`
		OperateType int       `json:"operate_type"`
		SalesID     string    `json:"sales_id"`
		ShopID      *[]string `json:"shop_id"`
		Type        int       `json:"type"`
		StartTime   string    `json:"start_time"`
		EndTime     string    `json:"end_time"`
		Areas1      string    `json:"areas1"`
		Areas2      string    `json:"areas2"`
		Areas3      string    `json:"areas3"`
		Page        int       `json:"page"`
		Limit       int       `json:"limit"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)
	db := mysql.NewDB()

	merchantID := c.GetString("merchant_id")
	var shopIDList = []string{}
	if params.ShopID != nil {
		shopIDList = append(shopIDList, *params.ShopID...)
	}

	data, err := statistics.DrawService{}.Draw(c.Request.Context(), db, merchantID, params.GoodsName,
		params.OperateType, params.SalesID, shopIDList, params.Type, params.StartTime, params.EndTime, params.Areas1, params.Areas2, params.Areas3, params.Page, params.Limit)
	response.JSON(c, data, err)
}

// 订单概览
func (s Statistics) OrderDesc(c *gin.Context) {
	var params struct {
		Page      int       `json:"page"`
		Limit     int       `json:"limit"`
		ShopID    *[]string `json:"shop_id"`
		StartTime string    `json:"start_time"`
		EndTime   string    `json:"end_time"`
		SalesID   string    `json:"sales_id"`
		Areas1    string    `json:"areas1"`
		Areas2    string    `json:"areas2"`
		Areas3    string    `json:"areas3"`
		Areas5    string    `json:"areas5"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)
	db := mysql.NewDB()

	merchantID := c.GetString("merchant_id")

	var shopIDList = []string{}
	if params.ShopID != nil {
		shopIDList = append(shopIDList, *params.ShopID...)
	}

	list, count, totalCount, err := statistics.OrderStatisticService{}.OrderDesc(c.Request.Context(), db, merchantID, params.Page, params.Limit,
		params.StartTime, params.EndTime, params.SalesID, params.Areas1, params.Areas2, params.Areas3, params.Areas5, shopIDList)
	response.JSON(c, gin.H{
		"list":        list,
		"count":       count,
		"total_count": totalCount,
	}, err)
}

// 订单概览 按时
func (s Statistics) HourOrderDesc(c *gin.Context) {
	var params struct {
		Page    int       `json:"page"`
		Limit   int       `json:"limit"`
		ShopID  *[]string `json:"shop_id"`
		Date    string    `json:"date"`
		SalesID string    `json:"sales_id"`
		Areas1  string    `json:"areas1"`
		Areas2  string    `json:"areas2"`
		Areas3  string    `json:"areas3"`
		Areas5  string    `json:"areas5"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)
	db := mysql.NewDB()

	merchantID := c.GetString("merchant_id")

	var shopIDList = []string{}
	if params.ShopID != nil {
		shopIDList = append(shopIDList, *params.ShopID...)
	}

	data, err := statistics.OrderStatisticService{}.HourOrderDesc(c.Request.Context(), db, merchantID, params.Page, params.Limit,
		params.Date, params.SalesID, params.Areas1, params.Areas2, params.Areas3, params.Areas5, shopIDList)
	response.JSON(c, data, err)
}

/**
 * 天数人流 【曝光统计】
 */
func (s Statistics) DatePerson(c *gin.Context) {
	var params struct {
		Page      int       `json:"page"`
		Limit     int       `json:"limit"`
		StartTime string    `json:"start_time"`
		EndTime   string    `json:"end_time"`
		ShopID    *[]string `json:"shop_id"`
		Areas1    string    `json:"areas1"`
		Areas2    string    `json:"areas2"`
		Areas3    string    `json:"areas3"`
		SalesID   string    `json:"sales_id"`
	}
	err := c.ShouldBindBodyWith(&params, binding.JSON)
	if err != nil {
		response.JSON(c, nil, errorx.New("参数错误", -1))
		return
	}
	merchantID := c.GetString("merchant_id")

	var shopIDList = []string{}
	if params.ShopID != nil {
		shopIDList = append(shopIDList, *params.ShopID...)
	}

	db := mysql.NewDB()
	data, count, err := robot.FaceCount{}.DatePerson(c.Request.Context(), db, merchantID, shopIDList, params.Areas3,
		params.StartTime, params.EndTime, params.SalesID, params.Page, params.Limit)
	// 返回json结果
	response.JSON(c, gin.H{
		"data":  data,
		"count": count, // 总的天数
	}, err)
}

// 小时曝光量
func (s Statistics) HourPerson(c *gin.Context) {
	var params struct {
		ShopID  *[]string `json:"shop_id"`
		Date    string    `json:"date"`
		SalesID string    `json:"sales_id"`
		Areas3  string    `json:"areas3"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)
	merchantID := c.GetString("merchant_id")

	var shopIDList = []string{}
	if params.ShopID != nil {
		shopIDList = append(shopIDList, *params.ShopID...)
	}

	merchantIDList, _ := common.Order{}.GetMerchantChildren(c.Request.Context(), merchantID, shopIDList)

	robotList, _, _ := dao.Robot{}.RobotList(c.Request.Context(), mysql.NewDB(), "", "", "", params.SalesID, "", "", "", "")
	var RobotNameList = []string{}
	for _, v := range robotList {
		if params.Areas3 != "" {
			locationID := strconv.Itoa(v.Areas3)
			if lo.Contains(strings.Split(params.Areas3, ","), locationID) {
				RobotNameList = append(RobotNameList, v.RobotName)
			}
		} else {
			RobotNameList = append(RobotNameList, v.RobotName)
		}
	}
	robotNames := strings.Join(RobotNameList, ",")
	data := dao.FaceCount{}.GetHourFaceCount(c.Request.Context(), dal.Q, merchantIDList, params.Date, robotNames)
	response.JSON(c, gin.H{
		"ai_face_count_hour":        data.FaceCount24,
		"ai_face_count_hour_robots": data.FaceCount24Robots,
	}, nil)
}

// 曝光流速
func (s Statistics) GetCenterPerson(c *gin.Context) {
	var params struct {
		Type      int       `json:"type"`
		Areas1    string    `json:"areas1"`
		Areas2    string    `json:"areas2"`
		Areas3    string    `json:"areas3"`
		Areas5    string    `json:"areas5"`
		StartTime string    `json:"start_time"`
		EndTime   string    `json:"end_time"`
		SalesID   string    `json:"sales_id"`
		ShopID    *[]string `json:"shop_id"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)

	merchantID := c.GetString("merchant_id")

	var shopIDList = []string{}
	if params.ShopID != nil {
		shopIDList = append(shopIDList, *params.ShopID...)
	}

	db := mysql.NewDB()
	data, totalCount, err := robot.FaceCount{}.GetFaceCount(c.Request.Context(), db, merchantID, params.Areas3, params.StartTime, params.EndTime, params.SalesID, shopIDList, params.Type, true)
	response.JSON(c, gin.H{
		"data":        data,
		"total_count": totalCount,
	}, err)
}

// 订单流速
func (s Statistics) GetCenterOrder(c *gin.Context) {
	var params struct {
		Areas1    string    `json:"areas1"`
		Areas2    string    `json:"areas2"`
		Areas3    string    `json:"areas3"`
		Areas5    string    `json:"areas5"`
		Compare   int       `json:"compare"`
		EndTime   string    `json:"end_time"`
		GoodsName string    `json:"goods_name"`
		SalesID   string    `json:"sales_id"`
		ShopID    *[]string `json:"shop_id"`
		StartTime string    `json:"start_time"`
		Type      int       `json:"type"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)

	merchantID := c.GetString("merchant_id")

	var shopIDList = []string{}
	if params.ShopID != nil {
		shopIDList = append(shopIDList, *params.ShopID...)
	}

	db := mysql.NewDB()
	data, totalCount, err := statistics.CenterOrderService{}.GetCenterOrder(c.Request.Context(), db, merchantID, params.Areas1, params.Areas2, params.Areas3,
		params.Areas5, params.Compare, params.GoodsName, params.SalesID, shopIDList, params.Type, params.StartTime, params.EndTime)
	response.JSON(c, gin.H{
		"data":        data,
		"total_count": totalCount,
	}, err)
}

// 创单与支付 【曝光与点击】
func (s Statistics) GetCreateAndPay(c *gin.Context) {
	var params struct {
		Type      int       `json:"type"`
		Areas1    string    `json:"areas1"`
		Areas2    string    `json:"areas2"`
		Areas3    string    `json:"areas3"`
		Areas5    string    `json:"areas5"`
		SalesID   string    `json:"sales_id"`
		ShopID    *[]string `json:"shop_id"`
		StartTime string    `json:"start_time"`
		EndTime   string    `json:"end_time"`
		Side      int       `json:"side"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)

	merchantID := c.GetString("merchant_id")

	var shopIDList = []string{}
	if params.ShopID != nil {
		shopIDList = append(shopIDList, *params.ShopID...)
	}

	db := mysql.NewDB()
	data, err := statistics.CreatePayStatistics{}.GetCreateAndPay(c.Request.Context(), db, merchantID, params.Side, params.Type, shopIDList, params.Areas1, params.Areas2,
		params.Areas3, params.Areas5, params.SalesID, params.StartTime, params.EndTime)
	response.JSON(c, data, err)
}

// 复购用户
func (s Statistics) GetRepeatUser(c *gin.Context) {
	var params struct {
		ShopID    *[]string `json:"shop_id"`
		Page      int       `json:"page"`
		Limit     int       `json:"limit"`
		UniqueID  string    `json:"unique_id"`
		StartTime string    `json:"start_time"`
		EndTime   string    `json:"end_time"`
		SalesID   string    `json:"sales_id"`
		GoodsName string    `json:"goods_name"`
		Areas1    string    `json:"areas1"`
		Areas2    string    `json:"areas2"`
		Areas3    string    `json:"areas3"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)

	db := mysql.NewDB()
	merchantID := c.GetString("merchant_id")

	var shopIDList = []string{}
	if params.ShopID != nil {
		shopIDList = append(shopIDList, *params.ShopID...)
	}

	data, PayUser, RepeatUser, Count, err := statistics.OrderStatisticService{}.GetRepeatUser(c.Request.Context(), db, merchantID, params.Page, params.Limit,
		params.UniqueID, params.StartTime, params.EndTime, params.SalesID, params.GoodsName, params.Areas1, params.Areas2, params.Areas3, shopIDList)
	response.JSON(c, gin.H{
		"list":        data,
		"pay_user":    PayUser,
		"repeat_user": RepeatUser,
		"count":       Count,
	}, err)
}

// 获取复购用户详情列表
func (s Statistics) GetRepeatUserDetail(c *gin.Context) {
	var params struct {
		Page      int    `json:"page"`
		Limit     int    `json:"limit"`
		UniqueID  string `json:"unique_id"`
		StartTime string `json:"start_time"`
		EndTime   string `json:"end_time"`
		SalesID   string `json:"sales_id"`
		GoodsName string `json:"goods_name"`
		Areas1    string `json:"areas1"`
		Areas2    string `json:"areas2"`
		Areas3    string `json:"areas3"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)

	db := mysql.NewDB()
	data, count, err := statistics.OrderStatisticService{}.GetRepeatUserDetail(c.Request.Context(), db, params.Page, params.Limit,
		params.UniqueID, params.StartTime, params.EndTime, params.SalesID, params.GoodsName, params.Areas1, params.Areas2, params.Areas3)
	response.JSON(c, gin.H{
		"data":  data,
		"count": count,
	}, err)
}

// 商品概览
func (s Statistics) GoodsDesc(c *gin.Context) {
	var params struct {
		StartTime string    `json:"start_time"`
		EndTime   string    `json:"end_time"`
		SalesID   string    `json:"sales_id"`
		GoodsName string    `json:"goods_name"`
		GoodsType int       `json:"goods_type"`
		DataType  int       `json:"data_type"`
		Areas1    string    `json:"areas1"`
		Areas2    string    `json:"areas2"`
		Areas3    string    `json:"areas3"`
		Areas5    string    `json:"areas5"`
		ShopID    *[]string `json:"shop_id"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)

	db := mysql.NewDB()
	merchantID := c.GetString("merchant_id")

	var shopIDList = []string{}
	if params.ShopID != nil {
		shopIDList = append(shopIDList, *params.ShopID...)
	}

	data, err := statistics.GoodsStatisticService{}.GoodsDesc(c.Request.Context(), db, merchantID, params.SalesID, params.StartTime, params.EndTime,
		params.GoodsName, params.GoodsType, params.DataType, params.Areas1, params.Areas2, params.Areas3, params.Areas5, shopIDList)
	response.JSON(c, data, err)
}

// 销售额占比
func (s Statistics) GetGoodsSoldCount(c *gin.Context) {
	var params struct {
		Page      int       `json:"page"`
		Limit     int       `json:"limit"`
		ShopID    *[]string `json:"shop_id"`
		SalesID   string    `json:"sales_id"`
		StartTime string    `json:"start_time"`
		EndTime   string    `json:"end_time"`
		Order     int       `json:"order"`
		Areas1    string    `json:"areas1"`
		Areas2    string    `json:"areas2"`
		Areas3    string    `json:"areas3"`
		Areas5    string    `json:"areas5"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)

	db := mysql.NewDB()
	merchantID := c.GetString("merchant_id")

	var shopIDList = []string{}
	if params.ShopID != nil {
		shopIDList = append(shopIDList, *params.ShopID...)
	}

	list, totalAmount, totalSoldCount, count, err := statistics.OrderStatisticService{}.GetGoodsSoldCount(c.Request.Context(), db, merchantID, params.SalesID, params.Areas1, params.Areas2, params.Areas3, params.Areas5, shopIDList, params.StartTime, params.EndTime, params.Page, params.Limit)
	response.JSON(c, gin.H{
		"list":             list,
		"total_amount":     totalAmount,
		"total_sold_count": totalSoldCount,
		"count":            count,
	}, err)
}

// 数据筛查
func (s Statistics) DailyReport(c *gin.Context) {
	var params struct {
		StartTime  int64  `json:"start_time"`  // 开始时间
		EndTime    int64  `json:"end_time"`    // 结束时间
		MerchantID string `json:"merchant_id"` // 指定商户
		RobotID    string `json:"robot_id"`    // 机器
		RobotName  string `json:"robot_name"`  // 机器
		LocationID string `json:"location_id"` // 商场
		CityID     string `json:"city_id"`     // 城市id
		DistrictID string `json:"district_id"` // 区县id
		GroupType  int    `json:"group_type"`  // 1机器 2商户 3商场
		DataType   int    `json:"data_type"`   // 数据类型[1订单 2曝光凝视 3点击 4任务]
		OrderType  string `json:"order_type"`  // 排序类型
		Summary    int    `json:"summary"`     // 汇总条件类型【0不汇总 1汇总】
		Page       int    `json:"page"`
		Limit      int    `json:"limit"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)

	merchantID := c.GetString("merchant_id")
	if params.RobotID == "" && params.RobotName != "" {
		params.RobotID = params.RobotName
	}
	list, total, summary, err := service.RobotDailyReport{}.DailyReport(c.Request.Context(), merchantID,
		params.StartTime, params.EndTime, params.MerchantID, params.RobotID, params.LocationID, params.CityID,
		params.DistrictID, params.GroupType, params.DataType, params.OrderType, params.Summary,
		params.Page, params.Limit)
	if params.Summary == 0 {
		response.JSON(c, gin.H{
			"total": total,
			"list":  list,
		}, err)
	} else {
		response.JSON(c, gin.H{
			"total":   total,
			"list":    list,
			"summary": summary,
		}, err)
	}
}

// 活跃趋势
func (s Statistics) RobotActiveRank(c *gin.Context) {
	var params struct {
		StartTime int64 `json:"start_time"`
		EndTime   int64 `json:"end_time"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)

	merchantID := c.GetString("merchant_id")
	data, err := service.RobotDailyReport{}.RobotActiveRank(c.Request.Context(), merchantID, params.StartTime, params.EndTime)
	response.JSON(c, data, err)
}

// 订单抵扣统计
func (s Statistics) TotalOrderDeduction(c *gin.Context) {
	var params struct {
		StartTime  int64  `json:"start_time"`
		EndTime    int64  `json:"end_time"`
		MerchantID string `json:"merchant_id"` // 商户id
		DistrictID string `json:"district_id"` // 区县id
		LocationID string `json:"location_id"` // 商场id
	}
	c.ShouldBindBodyWith(&params, binding.JSON)

	merchantID := c.GetString("merchant_id")
	data, err := statistics.StatisticsService{}.TotalOrderDeduction(c.Request.Context(), merchantID, params.StartTime, params.EndTime, params.MerchantID, params.DistrictID, params.LocationID)
	response.JSON(c, data, err)
}

// 数据对比
func (s Statistics) DataCompareNew(c *gin.Context) {
	var params struct {
		StartTime  int64  `json:"start_time"`  // 开始时间
		EndTime    int64  `json:"end_time"`    // 结束时间
		MerchantID string `json:"merchant_id"` // 商户
		RobotID    string `json:"robot_id"`    // 机器
		LocationID string `json:"location_id"` // 商场
		CityID     string `json:"city_id"`     // 城市
		GoodsID    string `json:"goods_id"`    // 商品id
		GoodsName  string `json:"goods_name"`  // 商品名称
	}
	c.ShouldBindBodyWith(&params, binding.JSON)

	merchantID := c.GetString("merchant_id")
	data, err := statistics.StatisticsService{}.DataCompareNew(c.Request.Context(), merchantID, params.StartTime,
		params.EndTime, params.MerchantID, params.RobotID, params.LocationID, params.CityID, params.GoodsID, params.GoodsName)
	response.JSON(c, data, err)
}

// 数据筛查
func (s Statistics) GoodsDailyReport(c *gin.Context) {
	var params struct {
		StartTime      int64  `json:"start_time"`       // 开始时间
		EndTime        int64  `json:"end_time"`         // 结束时间
		MerchantID     string `json:"merchant_id"`      // 指定商户
		RobotID        string `json:"robot_id"`         // 机器
		GoodsID        string `json:"goods_id"`         // 商品id
		GoodsName      string `json:"goods_name"`       // 商品名称
		RobotName      string `json:"robot_name"`       // 机器
		LocationID     string `json:"location_id"`      // 商场
		CityID         string `json:"city_id"`          // 城市id
		GroupType      int    `json:"group_type"`       // 1机器 2商户 3商场
		OrderType      string `json:"order_type"`       // 排序类型
		Summary        int    `json:"summary"`          // 汇总条件类型【0不汇总 1汇总】
		GoodsNameGroup int    `json:"goods_name_group"` // 商品分组【1 外层按照商品名称分组，2 内层按照groupType分组】
		Page           int    `json:"page"`
		Limit          int    `json:"limit"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)

	merchantID := c.GetString("merchant_id")
	if params.RobotID == "" && params.RobotName != "" {
		params.RobotID = params.RobotName
	}

	if params.GoodsNameGroup != 1 && params.GoodsNameGroup != 2 {
		params.GoodsNameGroup = 1 // 默认在外层
	}
	// 外层 && 非默认分组时，按照商品名称分组
	if params.GoodsNameGroup == 1 && params.GroupType != 0 {
		params.GroupType = 6
	}
	list, total, summary, err := service.GoodsDailyReport{}.DailyReport(c.Request.Context(), merchantID,
		params.StartTime, params.EndTime, params.MerchantID, params.GoodsID, params.GoodsName, params.RobotID, params.LocationID, params.CityID,
		params.GroupType, params.OrderType, params.Summary, params.Page, params.Limit)
	if params.Summary == 0 {
		response.JSON(c, gin.H{
			"total": total,
			"list":  list,
		}, err)
	} else {
		response.JSON(c, gin.H{
			"total":   total,
			"list":    list,
			"summary": summary,
		}, err)
	}
}

// 数据对比 -- 模板列表
func (s Statistics) DataCompareTemplateList(c *gin.Context) {
	merchantID := c.GetString("merchant_id")
	userID := c.GetString("user_id")
	data, _, err := statistics.StatisticsService{}.DataCompareTemplateList(c.Request.Context(), merchantID, userID)
	response.JSON(c, data, err)
}

// 数据对比 -- 模板保存
func (s Statistics) DataCompareTemplateSave(c *gin.Context) {
	var params struct {
		ID      string `json:"id"`
		Name    string `json:"name"`
		Content string `json:"content"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)
	merchantID := c.GetString("merchant_id")
	userID := c.GetString("user_id")

	err := statistics.StatisticsService{}.DataCompareTemplateSave(c.Request.Context(), merchantID, userID, params.ID, params.Name, params.Content)
	response.JSON(c, nil, err)
}

// 数据对比 -- 模板删除
func (s Statistics) DataCompareTemplateDelete(c *gin.Context) {
	var params struct {
		ID string `json:"id"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)
	merchantID := c.GetString("merchant_id")
	userID := c.GetString("user_id")

	err := statistics.StatisticsService{}.DataCompareTemplateDelete(c.Request.Context(), merchantID, userID, params.ID)
	response.JSON(c, nil, err)
}
